import time
from yuekao.Base.Base import Base
from selenium.webdriver.common.by import By
# 页面类
class Page(Base):
    # 点击登录
    login_loc=(By.LINK_TEXT,'登录')
    # 断言1：账号登录
    dy1_loc=(By.XPATH,'//*[@id="TANGRAM__PSP_11__changePwdCodeItem"]')
    # 输入正确的账号和密码
    username_loc=(By.NAME, 'userName')
    password_loc=(By.NAME,'password')
    # 勾选同意协议
    agree_loc=(By.ID,'TANGRAM__PSP_11__isAgree')
    # 点击登录
    loginbtn_loc=(By.ID,'TANGRAM__PSP_11__submit')

    #封装登录
    def login(self):
        self.click(self.login_loc)
    #断言
    def dy1(self):
        return self.text(self.dy1_loc)
    # 用户名
    def username(self):
        self.send_keys(self.username_loc,'18986670716')
    # 密码
    def password(self):
        self.send_keys(self.password_loc,'zxr2004zxr')
    # 同意协议
    def agree(self):
        self.click(self.agree_loc)
    # 登录按钮
    def loginbtn(self):
        self.click(self.loginbtn_loc)

   #  业务逻辑
    def baidu_luoji_login(self):
        self.open_url('https://www.baidu.com/')
        self.login()
        time.sleep(5)
        # 断言账号登录
        print(self.dy1())
        assert '账号登录'==self.dy1()
        self.username()
        self.password()
        self.agree()
        self.loginbtn()
        time.sleep(10)


